package com.scsj.supermarket.adapter;

import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.scsj.supermarket.R;
import com.scsj.supermarket.event.FirstEvent;
import com.scsj.supermarket.utils.RxBus;


import java.util.List;

/**
 * 搜索栏热点
 */

public class HotAdapter extends BaseQuickAdapter<String,BaseViewHolder> {

    public HotAdapter(List data) {
        super(R.layout.item_hot_solo_layout,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        helper.setText(R.id.name_tv,item);
        TextView textView= helper.getView(R.id.name_tv);

        final String s= textView.getText().toString();

        helper.addOnClickListener(R.id.name_tv);
        //将创建的View注册点击事件
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                RxBus.getDefault().post(new FirstEvent("SearchCode1",s));

            }
        });
    }
}
